




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MbPageManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MbPageManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MbPageManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "MbPage";
        }
		
		public MbPageEntity Insert(MbPageEntity _MbPageEntity)
		{
			return Insert(_MbPageEntity, "");
		}
		
		public MbPageEntity Insert(MbPageEntity _MbPageEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MbPageEntity, true);
				MbPageFields field = new MbPageFields();
                LogEntity(_MbPageEntity, field, AcInsert, controlId);
			}
			return _MbPageEntity;
		}

		
		public MbPageEntity Insert(Guid Id, string PageId, string PageCode, string PageName, string PageUrl, string ModCode, string RoleInit, bool IsEnable, DateTime CreatedDate)
		{
			MbPageEntity _MbPageEntity = new MbPageEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MbPageEntity.Id = Id;
				_MbPageEntity.PageId = PageId;
				_MbPageEntity.PageCode = PageCode;
				_MbPageEntity.PageName = PageName;
				_MbPageEntity.PageUrl = PageUrl;
				_MbPageEntity.ModCode = ModCode;
				_MbPageEntity.RoleInit = RoleInit;
				_MbPageEntity.IsEnable = IsEnable;
				_MbPageEntity.CreatedDate = CreatedDate;
				MbPageFields field = new MbPageFields();
                LogEntity(_MbPageEntity, field, AcInsert);
				adapter.SaveEntity(_MbPageEntity, true);
			}
			return _MbPageEntity;
		}

		public MbPageEntity Insert(Guid Id, string PageCode, string PageName, string PageUrl, string ModCode, string RoleInit, bool IsEnable, DateTime CreatedDate)
		{
			MbPageEntity _MbPageEntity = new MbPageEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MbPageEntity.Id = Id;
				_MbPageEntity.PageCode = PageCode;
				_MbPageEntity.PageName = PageName;
				_MbPageEntity.PageUrl = PageUrl;
				_MbPageEntity.ModCode = ModCode;
				_MbPageEntity.RoleInit = RoleInit;
				_MbPageEntity.IsEnable = IsEnable;
				_MbPageEntity.CreatedDate = CreatedDate;
				adapter.SaveEntity(_MbPageEntity, true);
				MbPageFields field = new MbPageFields();
                LogEntity(_MbPageEntity, field, AcInsert);
			}
			return _MbPageEntity;
		}
		
		public bool Update(MbPageEntity _MbPageEntity)
        {
            return Update(_MbPageEntity, "");
        }

		public bool Update(MbPageEntity _MbPageEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MbPageFields.PageId == _MbPageEntity.PageId);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MbPageEntity, filter);
				toReturn = true;
				
				MbPageFields field = new MbPageFields();
                LogEntity(_MbPageEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MbPageEntity _MbPageEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MbPageEntity, filter);
				toReturn = true;
				
				MbPageFields field = new MbPageFields();
                LogEntity(_MbPageEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(Guid Id, string PageId, string PageCode, string PageName, string PageUrl, string ModCode, string RoleInit, bool IsEnable, DateTime CreatedDate)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbPageEntity _MbPageEntity = new MbPageEntity(PageId);
				if (adapter.FetchEntity(_MbPageEntity))
				{
				
					_MbPageEntity.Id = Id;
					_MbPageEntity.PageCode = PageCode;
					_MbPageEntity.PageName = PageName;
					_MbPageEntity.PageUrl = PageUrl;
					_MbPageEntity.ModCode = ModCode;
					_MbPageEntity.RoleInit = RoleInit;
					_MbPageEntity.IsEnable = IsEnable;
					_MbPageEntity.CreatedDate = CreatedDate;
					adapter.SaveEntity(_MbPageEntity, true);
					toReturn = true;
					
					MbPageFields field = new MbPageFields();
					LogEntity(_MbPageEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(string PageId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbPageEntity _MbPageEntity = new MbPageEntity(PageId);
				if (adapter.FetchEntity(_MbPageEntity))
				{
					adapter.DeleteEntity(_MbPageEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MbPageEntity", null);
			}
		}
		
		
		public int DeleteById(Guid Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByPageId(string PageId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageId == PageId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByPageCode(string PageCode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageCode == PageCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByPageName(string PageName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageName == PageName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByPageUrl(string PageUrl)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageUrl == PageUrl);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByModCode(string ModCode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRoleInit(string RoleInit)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.RoleInit == RoleInit);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsEnable(bool IsEnable)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCreatedDate(DateTime CreatedDate)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MbPageEntity", filter);
			}
			return toReturn;
		}
		

		
		public MbPageEntity SelectOne(string PageId)
		{
			MbPageEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MbPageEntity _MbPageEntity = new MbPageEntity(PageId);
				if (adapter.FetchEntity(_MbPageEntity))
				{
					toReturn = _MbPageEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectAllLST()
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, null, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByIdLST(Guid Id)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByIdLST_Paged(Guid Id, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(Guid Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT_Paged(Guid Id, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageIdLST(string PageId)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageId == PageId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageIdLST_Paged(string PageId, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageId == PageId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByPageIdRDT(string PageId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageId == PageId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByPageIdRDT_Paged(string PageId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageId == PageId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageCodeLST(string PageCode)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageCode == PageCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageCodeLST_Paged(string PageCode, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageCode == PageCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByPageCodeRDT(string PageCode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageCode == PageCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByPageCodeRDT_Paged(string PageCode, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageCode == PageCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageNameLST(string PageName)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageName == PageName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageNameLST_Paged(string PageName, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageName == PageName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByPageNameRDT(string PageName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageName == PageName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByPageNameRDT_Paged(string PageName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageName == PageName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageUrlLST(string PageUrl)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageUrl == PageUrl);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByPageUrlLST_Paged(string PageUrl, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageUrl == PageUrl);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByPageUrlRDT(string PageUrl)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageUrl == PageUrl);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByPageUrlRDT_Paged(string PageUrl, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.PageUrl == PageUrl);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByModCodeLST(string ModCode)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByModCodeLST_Paged(string ModCode, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByModCodeRDT(string ModCode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByModCodeRDT_Paged(string ModCode, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByRoleInitLST(string RoleInit)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.RoleInit == RoleInit);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByRoleInitLST_Paged(string RoleInit, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.RoleInit == RoleInit);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRoleInitRDT(string RoleInit)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.RoleInit == RoleInit);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRoleInitRDT_Paged(string RoleInit, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.RoleInit == RoleInit);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByIsEnableLST(bool IsEnable)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByIsEnableLST_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT(bool IsEnable)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByCreatedDateLST(DateTime CreatedDate)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null);
			}
			return _MbPageCollection;
		}
		
		// Return EntityCollection<MbPageEntity>
		public EntityCollection<MbPageEntity> SelectByCreatedDateLST_Paged(DateTime CreatedDate, int PageNumber, int PageSize)
		{
			EntityCollection<MbPageEntity> _MbPageCollection = new EntityCollection<MbPageEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MbPageCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MbPageCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedDateRDT(DateTime CreatedDate)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedDateRDT_Paged(DateTime CreatedDate, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MbPageCollection = new EntityCollection(new MbPageEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MbPageFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MbPageCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
